<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<jsp:useBean id="user" class="entity.User" scope="session"/>
<jsp:useBean id="appointment" class="entity.Appointment" scope="request"/>
<jsp:useBean id="players" class="java.util.ArrayList" scope="request"/>
<html>
	<head>
		<title>Recreation Manager - Administracija mečeva</title>
		<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
		<link rel="stylesheet" type="text/css" href="theme.css">
		<script type="text/javascript" src="scripts/linkfader.js"></script>
	</head>
	<c:if test="${user.type!='A'}">
		<c:redirect url="./login.jsp" />
	</c:if>
	<body>
	<center>
	<c:import url="./header.jsp"></c:import>
	<table class="mainTable">
		<tr>
			<td width="200px" valign="top">
				<c:import url="./menu.jsp"></c:import>
			</td>			
			<td valign="top">
			<!-- itt kezdodik -->
			<table class="list">
				<thead>
					<tr>
						<th colspan="4"><h2>Administracija podataka o meču</h2></th>
					</tr>
					<tr>
						<th colspan="4"><h3>Termin</h3></th>
					</tr>
					<tr>
						<th>Lokacija:</th>
						<th>Datum:</th>
						<th>Od:</th>
						<th>Do:</th>		
					</tr>
				</thead>
				<tbody>
						<tr>
							<td>${appointment.location}</td>
							<td><fmt:formatDate value="${appointment.date}" pattern="dd.MM.yyyy" /> </td>
							<td><fmt:formatDate value="${appointment.from}" pattern="HH:mm"/></td>
							<td><fmt:formatDate value="${appointment.to}" pattern="HH:mm"/></td>
						</tr>
						<tr>
							<td colspan="4">&nbsp;</td>
						</tr>
				</tbody>		
			</table>
			<table class="list">
				<thead>
					<tr>
						<th colspan="7"><h3>Učesnici</h3></th>
					</tr>
					<tr>
						<th>Ime:</th>
						<th>Prezime:</th>
						<th>Tim:</th>
						<th>Broj golova:</th>					
						<th>Izbor tima:</th>
						<th>Uvećaj broj golova:</th>
						<th>Brisanje sa liste:</th>			
					</tr>
				</thead>
				<tbody>
					<c:forEach items="${players}" var="pl">
						<tr>
							<td>${pl.user.firstName}</td>
							<td>${pl.user.lastName}</td>
							<td>
								<c:if test="${pl.team=='H'}">
									domaćin
								</c:if>
								<c:if test="${pl.team=='G'}">
									gost
								</c:if>
								<c:if test="${pl.team==null}">
									---
								</c:if>									
							</td>
							<td>${pl.goal}</td>				
							<td>
								<a href="./AdminMatch?appId=${appointment.appointmentId}&homeId=${pl.playersId}">domaćin</a> - 
								<a href="./AdminMatch?appId=${appointment.appointmentId}&guestId=${pl.playersId}">gost</a>
							</td>				
							<td>
								<a href="./AdminMatch?appId=${appointment.appointmentId}&goalId=${pl.playersId}">uvećaj</a> - 
								<a href="./AdminMatch?appId=${appointment.appointmentId}&notGoalId=${pl.playersId}">smanji</a>
							</td>
							<td><a href="./AdminMatch?appId=${appointment.appointmentId}&playersId=${pl.playersId}">brisanje</a></td>
						</tr>
					</c:forEach>
					<tr>
						<td colspan="7" align="left"><a href="./AdminMatch?appId=${appointment.appointmentId}&addPlayer=true">Dodavanje učesnika</a></td>
					</tr>
					<tr>
						<td colspan="7">&nbsp;</td>
					</tr>
					<tr>
						<td colspan="7" align="left">Ako ste sve podatke uneli, unesite naziv utakmice i kliknite na 'Izgeneriši statistiku'</td>
					</tr>
					<tr>
						<td colspan="7" align="left">
						<form action="./AdminMatch" name="adminMatc" method="post"accept-charset="ISO-8859-1">
							Naziv utakmice:&nbsp;&nbsp;
							<input type="text" name="name">
							<input type="hidden" name="appId" value="${appointment.appointmentId}">		
							<input type="hidden" name="generate" value="true">&nbsp;&nbsp;&nbsp;	
							<input type="submit" name="submit" value="Izgeneriši statistiku" >								
						</form>
						</td>
					</tr>
				</tbody>		
			</table>
			<!-- itt vegzodik -->
			</td>
		</tr>
	</table>

	</center>
	</body>	
</html>